<?php

namespace App\Models\Company;
use Illuminate\Database\Eloquent\Model;

class MyOrder extends Model{
    //设置表的类型和表名
    protected $table='my_order';
    protected $primaryKey='id';
    protected $guarded = [];
    public $timestamps = true;
    //protected $fillable = [];

    /**
     * 要加上 where 条件上要加上 sign = 'pay'
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function myOrderWithCollOptions(){
        return $this->hasOne('App\Models\Common\CollOption','opt_id','pay_type');
    }

    /**
     * 套餐定单信息
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function myOrderWithVipPackage(){
        return $this->hasOne('App\Models\Company\VipPackage','id','vip_id');
    }

    /**
     * 定单与合同信息
     * @return array
     */
    public function myOrderWithContract()
    {
        return $this->hasOne('App\Models\Company\CompanyContract','uid','uid');
    }

    /**
     * 定单与企业用户信息
     * @return array
     */
    public function myOrderWithCompanyUser()
    {
        return $this->hasOne('App\Models\Company\CompanyUser','uid','uid');
    }
}